package com.yuanfeng.business.controller;

import com.yuanfeng.commoms.util.ResponseResult;
import com.yuanfeng.commoms.vo.shop.ShopMemberVO;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @ClassName ShopMemberGradController
 * @Description 会员等级
 * @Author hyq
 * @Date 2023/6/21 10:05
 * @Version 1.0
 **/
@RestController
@RequestMapping("/shop/memberGrade")
public class ShopMemberGradController extends BaseController{

    /**
     * 获取用户在店铺的会员等级
     *
     * @param shopMember
     * @return
     */
    @PostMapping("/getGradeByIds")
    public ResponseResult getGradeByIds(@RequestBody ShopMemberVO shopMember) {
        try {
            ShopMemberVO shopMember1 = shopMemberGradeService.getGradeByIds(shopMember.getUserId(), shopMember.getShopId());
            if (shopMember1.getGradeName() == null) {
                return ResponseResult.fail();
            }
            return ResponseResult.success(shopMember1.getGradeName());
        } catch (Exception e) {
            return ResponseResult.fail();
        }
    }
}
